package lab

import (
	"github.com/gin-gonic/gin"
	"github.com/lab-online/internal/lab/domain"
	"github.com/lab-online/internal/lab/handler"
	"github.com/lab-online/internal/lab/infra/mq"
	"github.com/lab-online/internal/lab/infra/oss"
	"github.com/lab-online/internal/lab/interface/rest"
	"github.com/lab-online/pkg/auth"
)

type Route struct {
	rest.LabHandler
	auth auth.Middleware
}

var (
	NewDomain = domain.New
	NewMQ     = mq.New
	NewOSS    = oss.New
)

func NewRoute(authMiddleware auth.Middleware, labDomain domain.LabDomain) *Route {
	h := handler.New(labDomain)
	return &Route{h, authMiddleware}
}

func (r *Route) Register(route *gin.RouterGroup) {
	lab := route.Group("/labs", r.auth(auth.RoleAll))

	lab.POST("/mimo-decode", r.MimoDecode()...)
	lab.POST("/mimo-plot", r.MimoPlot()...)
	lab.GET("/upload", r.auth(auth.RoleStudent), handler.GetUploadURLValidator, r.GetUploadURL)
}
